package name.luojun.DBhelper.model;
public class Column {
	String name;
	String field;
	String type;
	String dbtype;
	int lenth;
	int nullable;
	String defaultV;
	String generator;
	String sequence;
	public Column(String name, String dbtype, int lenth, int nullable, String defaultV, String type) {
		this.name = name;
		this.dbtype = dbtype;
		this.lenth = lenth;
		this.nullable = nullable;
		this.defaultV = defaultV;
		this.type = type;
	}
	public Column(String name, String dbtype, int lenth, int nullable, String defaultV) {
		this.name = name;
		this.dbtype = dbtype;
		this.lenth = lenth;
		this.nullable = nullable;
		this.defaultV = defaultV;
	}
	public Column() {
	}
	public String getField() {
		return field;
	}
	public void setField(String field) {
		this.field = field;
	}
	public String getGenerator() {
		return generator;
	}
	public void setGenerator(String generator) {
		this.generator = generator;
	}
	public String getSequence() {
		return sequence;
	}
	public void setSequence(String sequence) {
		this.sequence = sequence;
	}
	public String getDbtype() {
		return dbtype;
	}
	public void setDbtype(String dbtype) {
		this.dbtype = dbtype;
	}
	public String getDefaultV() {
		return defaultV;
	}
	public void setDefaultV(String defaultV) {
		this.defaultV = defaultV;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public String getType() {
		return type;
	}
	public void setType(String type) {
		this.type = type;
	}
	public int getLenth() {
		return lenth;
	}
	public void setLenth(int lenth) {
		this.lenth = lenth;
	}
	public int getNullable() {
		return nullable;
	}
	public void setNullable(int nullable) {
		this.nullable = nullable;
	}
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((dbtype == null) ? 0 : dbtype.hashCode());
		result = prime * result + ((defaultV == null) ? 0 : defaultV.hashCode());
		result = prime * result + lenth;
		result = prime * result + ((name == null) ? 0 : name.hashCode());
		result = prime * result + nullable;
		result = prime * result + ((type == null) ? 0 : type.hashCode());
		return result;
	}
	@Override
	public boolean equals(Object obj) {
		Column other = (Column) obj;
		if (dbtype == null) {
			if (other.dbtype != null)
				return false;
		} else if (!dbtype.equalsIgnoreCase(other.dbtype))
			return false;
		if (defaultV == null) {
			if (other.defaultV != null)
				return false;
		} else if (defaultV.length() > 0 && other.defaultV.length() > 0 && !defaultV.equalsIgnoreCase(other.defaultV))
			return false;
		if (lenth > 0 && other.lenth > 0)
			if (lenth != other.lenth)
				return false;
		if (name == null) {
			if (other.name != null)
				return false;
		} else if (name.length() > 0 && other.name.length() > 0 && !name.equalsIgnoreCase(other.name))
			return false;
		if (nullable != other.nullable)
			return false;
		return true;
	}
	@Override
	public String toString() {
		StringBuffer sb = new StringBuffer();
		sb.append(this.name + " " + this.dbtype);
		if (this.lenth > 0) {
			sb.append("(" + this.lenth + ")");
		}
		if (this.defaultV != null && this.defaultV.length() > 0) {
			sb.append(" DEFAULT " + defaultV);
		}
		if (this.nullable == 0) {
			sb.append(" not null");
		}
		return sb.toString();
	}
}